<!DOCTYPE html>
<html>
  
<head>
  <meta charset="utf-8">
  <meta name="author" content="Liu Encheng" />
  
  
  <title>坎坷的Hexo搭建经历(1) | Hexo</title>

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  
    <meta name="keywords" content="Hexo,坎坷的Hexo搭建经历,Hexo,坎坷的Hexo搭建经历," />
  

  
  <meta name="description" content="刘恩诚的博客站">

  

  

  
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async></script>
  

  

  

  <script>
  // theme-ad's config script
  // it can be used in every script
  
  window.AD_CONFIG = {
    leancloud: {"appid":"Hyq9wkH495DgNHWhDQCOfQSp-gzGzoHsz","appkey":"WaR7nrzhliHj9aVwdQzkdlGd","comment":false,"count":false},
    welcome: {"enable":false,"interval":30},
    start_time: "2021-01-28",
    passwords: ["655ede0c87493f70b7fc6ccdab571a9515f0bbd70c5155fe771f3ebcde376459", ],
    is_post: true,
    lock: false,
    author: "Liu Encheng",
    share: {"twitter":false,"facebook":false,"weibo":true,"qq":true,"wechat":true},
    mathjax: true,
    page_type: "",
    root: "/"
  };
</script>

  
<script src="/vendor/sha256.min.js"></script>
<script src="/js/auth.js"></script>
<script src="/js/index.js"></script>
<script src="/vendor/qrcode.min.js"></script>


  
    <link rel="icon" href="/images/favicon.ico">
    <link rel="apple-touch-icon" href="/images/touch-icon.png">
  

  <link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

  
<link rel="stylesheet" href="/css/index.css">
<link rel="stylesheet" href="/styles/components/highlight/highlight.css">


  
<meta name="generator" content="Hexo 5.3.0"></head>
  <body>
    <header class="site-header">
  <div class="site-header-brand">
    
      <span class="site-header-brand-title">
        <a href="/">万事不求人</a>
      </span>
    
    
  </div>
  <div class="site-header-right">
    <nav class="site-header-navigation">
      
        <a href="/" target="_self">首页</a>
      
        <a href="/archives/" target="_self">归档</a>
      
        <a href="/tags/" target="_self">标签</a>
      
        <a href="/categories/" target="_self">分类</a>
      
        <a href="/friends/" target="_self">友链</a>
      
        <a href="/about/" target="_self">关于</a>
      
        <a href="//gitee.com/DevBlog" target="_self">我的Gitee</a>
      
        <a href="//github.com/DeveloperMan-666" target="_self">我的Github</a>
      
    </nav>
    <div class="site-header-btn">
      
        <a href="https://github.com/DeveloperMan-666/" target="_blank" id="site-github">
          <i class="fa fa-github-alt"></i>
        </a>
      
      <a href="javascript:void(0);" id="site-search">
        <i class="fa fa-search"></i>
      </a>
      <a href="javascript:void(0);" id="site-nav-btn">
        <i class="fa fa-ellipsis-v"></i>
      </a>
    </div>
  </div>
</header>
<nav class="table-content" id="site-nav">
  <div class="table-content-title">
    <span>导航</span>
  </div>
  <div class="table-content-main">
    <ol class="toc">
      
        <li class="toc-item">
          <a href="/" target="_self">
            首页
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/archives/" target="_self">
            归档
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/tags/" target="_self">
            标签
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/categories/" target="_self">
            分类
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/friends/" target="_self">
            友链
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/about/" target="_self">
            关于
          </a>
        </li>
      
        <li class="toc-item">
          <a href="//gitee.com/DevBlog" target="_self">
            我的Gitee
          </a>
        </li>
      
        <li class="toc-item">
          <a href="//github.com/DeveloperMan-666" target="_self">
            我的Github
          </a>
        </li>
      
    </ol>
  </div>
</nav>
<div id="site-process"></div>
    <main>
      
  <div class="passage">
  <div class="passage-meta">
    <span>
      <i class="fa fa-calendar"></i>2021-01-26
    </span>
    
      <span>
        | <a href="/categories/Hexo/"><i class="fa fa-bookmark"></i>Hexo</a>
      </span>
    
    
      <span>
        | <i class="fa fa-unlock-alt"></i>UNLOCK
      </span>
    
  </div>
  <h1 class="passage-title">
    坎坷的Hexo搭建经历(1)
  </h1>
  
  <article class="passage-article">
    <h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>我从2019年就开始搞Hexo了，一直没有啥作为。</p>
<p>因为我搭建网站没有经验，经常搞了删，删了搞。</p>
<p>还有，我认识的世面不够广，毕竟我当时才9岁左右。</p>
<h1 id="安装Hexo"><a href="#安装Hexo" class="headerlink" title="安装Hexo"></a>安装Hexo</h1><h2 id="前言-1"><a href="#前言-1" class="headerlink" title="前言"></a>前言</h2><p>我是在Mac上搞的，最初是使用nvm安装。</p>
<p>几年了，Hexo网站库虽然经常删，但是并没有卸载。</p>
<h2 id="安装brew"><a href="#安装brew" class="headerlink" title="安装brew"></a>安装brew</h2><p>首先，大家如果有经验，应该知道raw.githubusercontent.com是无法正常访问的。(因为域名渲染)</p>
<p>所以我们需要定一个明确的IP地址给raw.githubusercontent.com才行。</p>
<p>现在开始编辑/etc/hosts</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo vim /etc/hosts</span><br></pre></td></tr></table></figure>
<h3 id="老手可不看"><a href="#老手可不看" class="headerlink" title="老手可不看"></a>老手可不看</h3><p>长按向下键，直到页面没有滚动。</p>
<p>按下i。</p>
<p>输入完成后按下esc，输入英文冒号q(:q)</p>
<h3 id="继续"><a href="#继续" class="headerlink" title="继续"></a>继续</h3><p>打开Vim，输入</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">199.232.28.133	raw.githubusercontent.com</span><br></pre></td></tr></table></figure>
<p>即可。</p>
<p>然后再使用brew的经典安装命令</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/bin/bash -c <span class="string">&quot;<span class="subst">$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)</span>&quot;</span></span><br></pre></td></tr></table></figure>
<p>此命令不可在Root用户下执行。</p>
<h2 id="安装NPM"><a href="#安装NPM" class="headerlink" title="安装NPM"></a>安装NPM</h2><p>现在安装完brew，就比较简单了。</p>
<p>使用brew安装node.js，由于npm和node.js是依赖关系，所以也会安装。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">brew install nodejs</span><br></pre></td></tr></table></figure>
<p>等它一下。</p>
<p>现在再使用Vim编辑~/.bash_profile，输入以下内容：</p>
<blockquote>
<p>export NVM_DIR=”$HOME/.nvm”</p>
<p>[ -s “$NVM_DIR/nvm.sh” ] &amp;&amp; . “$NVM_DIR/nvm.sh” # This loads nvm</p>
<p>[ -s “$NVM_DIR/bash_completion” ] &amp;&amp; . “$NVM_DIR/bash_completion” # This loads nvm bash_completion</p>
</blockquote>
<p>然后</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">source</span> ~/.bash_profile</span><br></pre></td></tr></table></figure>
<p>便安装完成了</p>
<h2 id="安装CNPM"><a href="#安装CNPM" class="headerlink" title="安装CNPM"></a>安装CNPM</h2><p>由于npm采用的是国外源，所以我们需要使用国内映像版：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install -g cnpm --registry=https://registry.npm.taobao.org</span><br></pre></td></tr></table></figure>
<p>之后再网上碰到的任何npm xxx命令皆可用cnpm xxx代替。</p>
<h2 id="安装Hexo-1"><a href="#安装Hexo-1" class="headerlink" title="安装Hexo"></a>安装Hexo</h2><p>现在安装完了CNPM，可以开始安装Hexo了。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cnpm install hexo -g</span><br></pre></td></tr></table></figure>
<p>安装完了hexo，可以开始创建Hexo仓库了。</p>
<h1 id="创建Hexo仓库"><a href="#创建Hexo仓库" class="headerlink" title="创建Hexo仓库"></a>创建Hexo仓库</h1><p>先创建你的博客文件夹，注意一定要是空的。</p>
<p>输入</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo init</span><br></pre></td></tr></table></figure>
<p>它可能会比较久，不过没关系。</p>
<p>如果报错，翻译后大致为文件夹不是空的，那就是.*文件在作怪。</p>
<p>输入</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rm .*</span><br></pre></td></tr></table></figure>
<h1 id="尾声"><a href="#尾声" class="headerlink" title="尾声"></a>尾声</h1><p>好了，本期就分享到这里了。</p>
<p>有缘下期在见~</p>
<p>我感觉能被踩到的坑我都踩到了😂😂😂</p>

  </article>
  <aside class="table-content" id="site-toc">
  <div class="table-content-title">
    <i class="fa fa-arrow-right fa-lg" id="site-toc-hide-btn"></i>
    <span>目录</span>
  </div>
  <div class="table-content-main">
    <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%89%8D%E8%A8%80"><span class="toc-text">前言</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85Hexo"><span class="toc-text">安装Hexo</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%89%8D%E8%A8%80-1"><span class="toc-text">前言</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85brew"><span class="toc-text">安装brew</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%80%81%E6%89%8B%E5%8F%AF%E4%B8%8D%E7%9C%8B"><span class="toc-text">老手可不看</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BB%A7%E7%BB%AD"><span class="toc-text">继续</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85NPM"><span class="toc-text">安装NPM</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85CNPM"><span class="toc-text">安装CNPM</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85Hexo-1"><span class="toc-text">安装Hexo</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%88%9B%E5%BB%BAHexo%E4%BB%93%E5%BA%93"><span class="toc-text">创建Hexo仓库</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%B0%BE%E5%A3%B0"><span class="toc-text">尾声</span></a></li></ol>
  </div>
</aside>
  
    <aside class="passage-copyright">
      <div>本文作者: 刘恩诚</div>
      
        <div>
          原文链接: 
          <a href="" target="_blank">https://devblog.gitee.io/post/9fe805e.html</a>
        </div>
      
      <div>
        版权声明: 本博客所有文章除特别声明外, 均采用 <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> 许可协议. 转载请注明出处!
      </div>
    </aside>
  
  
    <div class="passage-tags">
     
      <a href="/tags/Hexo/"><i class="fa fa-tags"></i>Hexo</a>
     
      <a href="/tags/%E5%9D%8E%E5%9D%B7%E7%9A%84Hexo%E6%90%AD%E5%BB%BA%E7%BB%8F%E5%8E%86/"><i class="fa fa-tags"></i>坎坷的Hexo搭建经历</a>
    
    </div>
  
</div>

    </main>
    
    <div class="site-footer-wrapper">
  <footer class="site-footer">
    
      
        <div class="site-footer-col">
          <h5 class="site-footer-title">联系方式</h5>
          
            <span class="site-footer-item">
              <a href="mailto:3591695778@qq.com" target="_self">QQ邮箱</a>
            </span>
          
            <span class="site-footer-item">
              <a href="tencent://message?uin=3591695778" target="_self">QQ</a>
            </span>
          
        </div>
      
        <div class="site-footer-col">
          <h5 class="site-footer-title">我的博客站</h5>
          
            <span class="site-footer-item">
              <a href="/" target="_self">Gitee站</a>
            </span>
          
            <span class="site-footer-item">
              <a href="https://csdn.net/liuencheng2020" target="_blank">CSDN站</a>
            </span>
          
        </div>
      
    
    <div class="site-footer-info">
      <i class="fa fa-clock-o"></i> 本站已稳定运行<span id="site-time"></span>
    </div>
    
    
      <div class="site-footer-info">
        <i class="fa fa-at"></i> Email:3591695778@qq.com
      </div>
    
    <div class="site-footer-info">
      <i class="fa fa-copyright"></i> 
      2019 <a href="https://github.com/dongyuanxin/theme-ad/" target="_blank">Theme-AD</a>.
      Created by <a href="https://godbmw.com/" target="_blank">GodBMW</a>.
      All rights reserved.
    </div>
  </footer>
</div>
    <div id="site-layer" style="display:none;">
  <div class="site-layer-content">
    <div class="site-layer-header">
      <span class="site-layer-header-title" id="site-layer-title"></span>
      <i class="fa fa-close" id="site-layer-close"></i>
    </div>
    <div class="site-layer-body" id="site-layer-container">
      <div class="site-layer-input" id="site-layer-search" style="display: none;">
        <div class="site-layer-input-choose">
          <a href="javascript:void(0);" title="Change Search Engine">Google</a>
        </div>
        <input type="text">
        <i class="fa fa-search"></i>
      </div>
      
      <div id="site-layer-welcome" style="display:none;"></div>
    </div>
  </div>
</div>
    

<div class="bottom-bar">
  <div class="bottom-bar-left">
    <a href="/post/22d3d39d.html" data-enable="true">
      <i class="fa fa-arrow-left"></i>
    </a>
    <a href="javascript:void(0);" data-enable="false">
      <i class="fa fa-arrow-right"></i>
    </a>
  </div>
  <div class="bottom-bar-right">
    <a href="javascript:void(0);" data-enable="true" id="site-toc-show-btn">
      <i class="fa fa-bars"></i>
    </a>
    
    <a href="javascript:void(0);" id="site-toggle-share-btn">
      <i class="fa fa-share-alt"></i>
    </a>
    
    <a href="javascript:void(0);" id="back-top-btn">
      <i class="fa fa-chevron-up"></i>
    </a>
  </div>
</div>
    <div id="share-btn">
  
  
  
    <a id="share-btn-weibo" href="javascript:void(0);" target="_blank">
      <i class="fa fa-weibo"></i>
    </a>
  
  
    <a id="share-btn-qq" href="javascript:void(0);" target="_blank">
      <i class="fa fa-qq"></i>
    </a>
  
  
    <a id="share-btn-wechat" href="javascript:void(0);" target="_blank">
      <i class="fa fa-wechat"></i>
    </a>
  
</div>
    


  <script async>
  (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      if (curProtocol === 'https') {
          bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
      }
      else {
          bp.src = 'http://push.zhanzhang.baidu.com/push.js';
      }
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
  })();
  </script>




    
  </body>
</html>